### Imports
import MySQLdb
import _mysql_exceptions

### connect to the hunter SQL database
mysql_host = '112.124.1.3'
mysql_port = 3306
mysql_user = 'hunter_guest'
mysql_passwd = 'hunter_guest'
mysql_db = 'hunter'

conn = MySQLdb.connect(host=mysql_host, port=mysql_port,
	user=mysql_user, passwd=mysql_passwd, db=mysql_db, charset='utf8')
cursor = conn.cursor()

### create auth_group table
try:
	cursor.execute('DROP TABLE auth_group')
except _mysql_exceptions.OperationalError:
	pass
cursor.execute('CREATE TABLE auth_group(id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(200))')

"""
### create auth_permission table
try:
	cursor.execute('DROP TABLE auth_permission')
except _mysql_exceptions.OperationalError:
	pass
cursor.execute('CREATE TABLE auth_permission(id INT AUTO_INCREMENT PRIMARY KEY, content_type_id INT, codename VARCHAR(200), name VARCHAR(200))')

### create auth_user table
try:
	cursor.execute('DROP TABLE auth_user')
except _mysql_exceptions.OperationalError:
	pass
cursor.execute('CREATE TABLE auth_user(id INT AUTO_INCREMENT PRIMARY KEY, password VARCHAR(200), last_login DATETIME, is_superuser BINARY, username VARCHAR(200), first_name VARCHAR(25), last_name VARCHAR(200), email VARCHAR(200), is_staff BINARY, is_active BINARY, date_joined DATE)')


### create django_admin_log table
try:
	cursor.execute('DROP TABLE django_admin_log')
except _mysql_exceptions.OperationalError:
	pass
cursor.execute('CREATE TABLE django_admin_log(id INT AUTO_INCREMENT PRIMARY KEY, action_time TIME, user_id INT, content_type_id INT, object_id INT, object_repr VARCHAR(255), action_flag BINARY, change_message LONGTEXT)')


### create products_product table
try:
	cursor.execute('DROP TABLE products_product')
except _mysql_exceptions.OperationalError:
	pass
cursor.execute('CREATE TABLE products_product(id INT AUTO_INCREMENT PRIMARY KEY, product_identifier VARCHAR(200), product_name VARCHAR(200), website VARCHAR(200), category VARCHAR(200), edit_date DATETIME)')

### create products_feature table
try:
	cursor.execute('DROP TABLE products_feature')
except _mysql_exceptions.OperationalError:
	pass
cursor.execute('CREATE TABLE products_feature(id INT AUTO_INCREMENT PRIMARY KEY, product_identifier VARCHAR(200), feature_name VARCHAR(200), score DECIMAL(10,5))')
"""
### Close connection
cursor.close()
conn.close()